<!--
 * @Description: 
 * @Author: dh
 * @Date: 2021-08-19 17:18:39
 * @LastEditors: dh
 * @LastEditTime: 2021-09-15 11:42:27
-->
<!-- B.html -->
<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>B</title>
		<button type="button" onclick="sendA()">发送A页面消息</button>
	</head>

	<body>
		<h1>B 页面</h1>
		<span></span>
		<script>
			// window.name = 'B'
			function sendA() {
				// 打开该窗口的window引用
				let targetWindow = window.opener;

				// targetWindow.postMessage('Hello A', "http://127.0.0.1:5500/");
				targetWindow.postMessage('Hello A');

				targetWindow.changeColor('blue');
			}
		</script>
	</body>
</html>
